import "reflect-metadata";
import { DataSource } from "typeorm";

import { createEsiSdk } from "@scvzerng/esi-163";
import * as entities from "./entities";

export const database = new DataSource({
  type: "better-sqlite3",
  database: "../eve-helper.db",
  synchronize: true,
  logging: false,
  //@ts-ignore
  entities: Object.values(entities),
});

export const esi = createEsiSdk("https://ali-esi.evepc.163.com/latest");

export const initDatabase = async () => {
  if (!database.isInitialized) {
    await database.initialize();
  }
};
